package com.googlecode.jvmpart;

import java.util.Map;
import java.util.Set;

/**
 * Manager processes status and persistent
 * @author chunzhan.he
 *
 */
public interface ProcessManager {
	/**
	 * Sub process start, notified when the sub process executed
	 * 
	 * @param ppid
	 *            parent process id
	 * @param ppidTimestamp
	 *            parent process id timestamp
	 * @param pid
	 *            child process id
	 * @param params
	 *            child process parameters
	 */
	public void start(String ppid, long ppidTimestamp, String pid,
			Map<String, String> params);

	/**
	 * Sub process stop, notified when the sub process exit normal
	 * 
	 * @param ppid
	 *            parent process id
	 * @param ppidTimestamp
	 *            parent process id timestamp
	 * @param pid
	 *            child process id
	 * @param params
	 *            child process parameters
	 */
	public void stop(String ppid, long ppidTimestamp, String pid,
			Map<String, String> params);

	/**
	 * main process exit normal
	 * 
	 * @param ppid
	 *            parent process id
	 * @param ppidTimestamp
	 *            parent process id timestamp
	 * @param set
	 *            processes execution context
	 */
	public void exit(String ppid, long ppidTimestamp, Set<ProcessExecution> set);

	/**
	 * notified by kill process
	 * 
	 * @param ppid
	 *            parent process id
	 */
	public void kill(String ppid);

	/**
	 * sub process error, notified by sub process when error
	 * 
	 * @param ppid
	 *            parent process id
	 * @param ppidTimestamp
	 *            parent process id timestamp
	 * @param pid
	 *            child process id
	 * @param e
	 *            child process error
	 */
	public void error(String ppid, long ppidTimestamp, String pid, Throwable e);
}
